import { Modal } from 'antd'
import React, { useMemo } from 'react'
import { formatDate } from '@js/tool'
import FileList from '@components/FileList/Index'
import DetailInfo from '@components/DetailInfo'

function Main ({ data, visible, hide, refreshFn }) {
  const formData = useMemo(() => {
    if (!data) {
      return []
    }
    const d = data
    return [
      { k: '机构名称', v: d.name },
      { k: '地址', v: d.address },
      { k: '机构简称', v: d.sname },
      { k: '设立时间', v: d.establish_datetime ? formatDate(d.establish_datetime, 'YYYY-MM-DD') : '' },
      { k: '机构英文名称', v: d.enname },
      { k: '工作人员数量', v: d.staff_num },
      { k: '机构英文简称', v: d.senname },
      { k: '仲裁员数量', v: d.arbitrator_num },
      { k: '机构代码', v: d.idno },
      { k: '备注', v: d.remark },
      { k: '负责人/法定代表人', v: d.principal },
      { k: '联系电话', v: d.tel },
      { k: '所属机构', v: d.pname },
      { k: '附件', v: <FileList value={d.file} /> }
    ]
  }, [data])
  return (
    <Modal title='分支机构详情' width={1000} open={visible} onCancel={hide} forceRender footer={null}>
      <DetailInfo data={formData} />
    </Modal>
  )
}

export default Main
